package main

import (
	"fmt"
	"github.com/pkg/errors"
	"log"
)

var ErrorNoRows = errors.New("ErrNoRows 没有查询到相关信息")

type UserData struct {
}

//模拟查询  -- 数据库函数
func Query(sqlRow string) (*[]UserData, error) {
	if sqlRow == "" {
		return nil, ErrorNoRows
	}
	return &[]UserData{}, nil
}

//业务查询   dao层函数
func Find(sqlRow string) (*[]UserData, error) {

	UserData, err := Query(sqlRow)
	if err != nil {
		return nil, errors.Wrap(err, "dao Find")
	}
	return UserData, nil
}

//模拟model逻辑层
func main() {
	sqlRow := ""
	resData, err := Find(sqlRow)
	if err != nil && !errors.Is(err, ErrorNoRows) {
		log.Panic(err)
		return
	}

	//do something with redData
	fmt.Println(resData)
}
